/*
 * Guide.java
 *
 * Created on 20. huhtikuuta 2007, 1:08
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package flowchart.nodes;


import java.awt.*;

/**
 *
 * @author jl
 */
public class Guide extends AbstractGraphicsObject {
    protected int x, y, width;
    
    /** Creates a new instance of Guide */
    public Guide(int x, int y, int width) {
        this.x = x;
        this.y = y;
        this.width = width;
        resetBounds();
    }
    
    protected void resetBounds() {
        if (bounds == null) {
            setBounds(new Rectangle(x-width/2, y-width/2, width, width));
        } else {
            bounds.setBounds(x-width/2, y-width/2, width, width);
        }
    }
    
    public int getX() { return x; }
    public void setX(int x) { 
        this.x = x; 
        resetBounds();
    }
    
    public int getY() { return y; }
    public void setY(int y) {
        this.y = y;
        resetBounds();
    }
    
    public int getWidth() { return width; }
    public void setWidth(int width) {
        this.width = width;
        resetBounds();
    }
    
    public void draw(Graphics2D g) {
        if (bgColor != null) {
            Color old = g.getColor();
            g.setColor(bgColor);
            g.fillRect(0, y-width/2, 1000, width);
            g.fillRect(x-width/2, 0, width, 1000);
            g.setColor(old);
        } else {
            g.fillRect(0, y-width/2, 1000, width);
            g.fillRect(x-width/2, 0, width, 1000);
        }
    }
    
}
